import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err);
};
const routes = [
    {
        path: '/',
        redirect: '/one'
    },
    {
        path: '/home',
        name: 'home',
        component: () => import('@/views/right/home'),
        meta: {
            title: '首页'
        }
    },
    {
        path: '/one',
        name: 'one',
        component: () => import('@/views/right/one'),
        meta: {
            title: '诗词'
        }
    },
    {
        path: '/two',
        component: () => import('@/views/right/two'),
        meta: {
            title: '励志句子'
        }
    },
    {
        path: '/three',
        component: () => import('@/views/right/three'),
        meta: {
            title: '毒鸡汤'
        }
    }
];

const router = new VueRouter({
    routes,
    mode: 'history'
});
router.beforeEach((to, from, next) => {
    window.document.title = to.meta.title;
    next();
});
export default router;
